import { defineStore } from 'pinia';
import { store } from '@/store';

   
import { createLocalStorage } from '@/utils/cache';
 

const ls = createLocalStorage();


const localeUserData: UserData = {
  accessToken: '',
  refreshToken: 'String',
  jti: 'String',
  userInfo:{
    userInfo:{
      bid: '',
      userType:'',
      userName:'',
      realName:'',
      loginCount:'',
      sex:'',
      age:'',
      email:'',
      phone:'',     
    },
    currentPost:''
  }
}

export interface UserInfo {
  bid: String;
  userType:String;
  userName:String;
  realName:String;
  loginCount:String;
  sex:String;
  age:String;
  email:String;
  phone:String;
}
export interface UserMessage {
  userInfo:UserInfo;
  currentPost:String;
}

export interface UserData {
  accessToken: String;
  refreshToken: String;
  jti: String;
  userInfo:UserMessage;
}

export const useInfoStore = defineStore({
  id: 'app-login',
  state: (): UserData => (localeUserData),
  getters: {
 
  },
  actions: {
    setUserData(userData:UserData) {
      this.$state = userData;
    }
  },
});

// Need to be used outside the setup
export function useInfoStoreWithOut() {
  return useInfoStore(store);
}
